package main

import (
	"learngo/crawler/config"
	"learngo/crawler/engine"
	"learngo/crawler/persist"
	"learngo/crawler/scheduler"
	"learngo/crawler/xcar/parser"
)

//http://eagleliu.com:9200/car_profile/xcar/_search?size=100
//curl -XDELETE 'http://eagleliu.com:9200/car_profile'
func main() {

	itemChan, err := persist.ItemSaver(
		config.ElasticIndex)
	if err != nil {
		panic(err)
	}

	//e := engine.ConcurrentEngine{
	//	Scheduler: &scheduler.SimpleScheduler{},
	//	WorkerCount:100,
	//}

	e := engine.ConcurrentEngine{
		Scheduler: &scheduler.QueuedScheduler{},
		WorkerCount:100,
		ItemChan:         itemChan,
		RequestProcessor: engine.Worker,
	}
	//e.Run(engine.Request{
	//	Url:"http://www.zhenai.com/zhenghun",
	//	ParserFunc: parser.ParserCityList,
	//})

	e.Run(engine.Request{
		Url:"http://newcar.xcar.com.cn",
		Parser: engine.NewFuncParser(
			parser.ParseCarList,
			config.ParseCarList),
	})
}
